#ifndef __PINTOS_FDTABLE_H__
#define __PINTOS_FDTABLE_H__

#include "file.h"
#include "threads/synch.h"
#include "threads/thread.h"

#define NR_OPEN_DEFAULT  16

struct file;

struct files_struct
{
  struct lock file_lock;
  int next_fd;
  int max_fd;
  struct file **fd;
  struct file *fd_array[NR_OPEN_DEFAULT];
};

int insert_filp(struct files_struct *fs, struct file *filp);
void init_file_struct (struct files_struct *fs);
void free_file_struct (struct files_struct *fs);

void remove_fd_array(struct files_struct *fs);

void sys_close(struct thread *cur, int fd);
void close_all_files(struct files_struct *fs);

#endif  /* __PINTOS_FDTABLE_H__ */
